# json数据的爬取，以爬取豆瓣电影的排行榜信息为例
# 先爬取网页html信息
import requests

# 定义请求网址
url = 'https://movie.douban.com/typerank?type_name=%E5%96%9C%E5%89%A7&type=24&interval_id=100:90&action='

# 定义请求头
headers = {
    "cache-control": "max-age=0",
    "cookie": "ll=\"118241\"; bid=UUvk3jIXsgo; _pk_id.100001.4cf6=f9398bc300c3539b.1734533818.; _vwo_uuid_v2=D6E3F6D1B0DCD471AB7B45A792836B42C|be84e464bd185273bda07f26774ae825; __yadk_uid=vIpU6QZzubYJ2H2BuUqRgp8r3I1YttSm; __utma=30149280.932035719.1734533814.1741513195.1745941999.3; __utmc=30149280; __utmz=30149280.1745941999.3.3.utmcsr=localhost:63342|utmccn=(referral)|utmcmd=referral|utmcct=/pythonProject/day8/day08/douban.html; __utmb=30149280.1.10.1745941999; __utma=223695111.2068876059.1734533818.1741513199.1745942001.3; __utmb=223695111.0.10.1745942001; __utmc=223695111; __utmz=223695111.1745942001.3.3.utmcsr=douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1745942001%2C%22https%3A%2F%2Fwww.douban.com%2F%22%5D; _pk_ses.100001.4cf6=1; ap_v=0,6.0",
    "priority": "u=0, i",
    "sec-ch-ua": "\"Google Chrome\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "none",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"
}

# 发起网络请求，并保存
response = requests.get(url, headers=headers)
with open('douban.html', 'wb') as f:
    f.write(response.content)
# 发现get请求得到的内容并没有需要的信息
